package com.bangyo.file;

import java.io.Serializable;

import org.sothis.util.ObjectUtils;

/**
 * 文件类型。遵照RFC2045。<br />
 * image/jpeg: JPEG图片。<br />
 * image/gif: GIF图片。<br />
 * image/png: PNG图片。<br />
 * video/x-msvideo: Microsoft AVI格式视频。<br />
 * video/quicktime: Apple MOV格式视频。<br />
 * video/x-ms-wmv: Microsoft Windows Media Video格式视频。<br />
 * application/x-shockwave-flash: Macromedia SWF格式。
 */
public enum MimeTypeName implements Serializable
{
    JPEG("image/jpeg"), GIF("image/gif"), PNG("image/png"), IMAGE("image");

    private String mimeTypeName = null;

    private MimeTypeName(String mimeTypeName)
    {
        this.mimeTypeName = mimeTypeName;
    }

    public String getMimeTypeName()
    {
        return mimeTypeName;
    }

    public static MimeTypeName toMimeTypeName(String mimeTypeName)
    {
        for (MimeTypeName _mimeTypeName:MimeTypeName.values())
        {
            if (ObjectUtils
                .equal(_mimeTypeName.getMimeTypeName(), mimeTypeName))
            {
                return _mimeTypeName;
            }
        }
        return null;
    }

    @Override
    public String toString()
    {
        return this.mimeTypeName;
    }
}
